#ifndef __IF_SOC_TIMER_H__
#define __IF_SOC_TIMER_H__

#include <functional>
#include <stdint.h>
#include "soc/iperipheral.h"
#include "soc/soc_comm_def.h"

/// @brief 
class IF_SOC_Timer : public IPeripheralEx<IF_SOC_Timer, SOC_TIMER_MAX>
{
public:
   using ElapsedCallBack = std::function<void(IF_SOC_Timer & sender)>;
   using OCCallBack = std::function<void(IF_SOC_Timer & sender, int channel)>;

public:
   //base 
   virtual void SetPerscaler(int div) = 0;
   virtual int GetPerscaler() = 0;
   virtual void SetPeriod(int val) = 0;
   virtual int GetPeriod() = 0;
   virtual void SetTimerCount(uint32_t val) = 0;
   virtual uint32_t GetTimerCount() = 0;
   virtual void StartBase() = 0;
   virtual void StopBase() = 0;
   virtual void StartBase_IT() = 0;
   virtual void StopBase_IT() = 0;

   virtual void SetElapsedCallBack(ElapsedCallBack cb) = 0;
   virtual void RaiseElapsed_IRQ() = 0;

   //pwm
   virtual void StartPwm(int ch) = 0;
   //驱动互补pwm
   virtual void StartPwmPN(int ch) = 0;
   virtual void StopPwm(int ch) = 0;
   //duty 可以是小数
   virtual void SetPwmDuty(int ch, float duty) = 0;
   virtual void SetPwmDutyP(int ch, float percent) = 0;
   virtual void SetCompare(int ch, int val) = 0;
   virtual int GetCompare(int ch) = 0;

   //oc
   virtual void StartOc_IT(int ch) = 0;
   virtual void StopOc_IT(int ch) = 0;
   virtual void SetNextPoint(int ch, int us) = 0;

   virtual void SetOcCallBack(OCCallBack cb) = 0;
   virtual void RaiseOc_IRQ(int ch) = 0;
};


#endif // __IF_SOC_TIMER_H__
